<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改供应链用户</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<link href="${BasePath}/res/css/common/base.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery-validation/jquery.validate.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.validate.method.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<style type="text/css">
    body{ font-size:12px;}
    .l-table-edit {}
    .l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-cancel{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    .l-verify-tip{ left:230px; top:120px;}
    .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
	#select1,#select2{width:200px; height:300px; margin:0px;padding:5px; }
	.sel-div{border:1px solid #ccc;width:200px; overflow:hidden; margin-left:50px;}
	.a-up,.a-down{display: block;border: 1px solid #ccc;text-decoration:none;width:200px; background:#F2F2F2; text-align:center; height:25px; line-height:25px;cursor:pointer; letter-spacing:2px; zoom:1; margin-left:50px;}
	.a-up{border-bottom:none;}
	.a-down{border-top:none;}
	.a-right,.a-left{display:block; border:1px solid #ccc; width:100px; height:25px; line-height:25px; background:#F2F2F2;margin:15px; cursor:pointer; margin-left:20px;}
	.a-left{margin-top:20px;}
	#left_td{position: relative; left: -50px;}
</style>
</head>
<body style="padding:10px">
<div class="navbar"><span>您当前的位置：系统管理 &gt;修改供应链用户 </span></div><br>
<form name="form1" method="post" action="modifyUser.do" id="form1" onsubmit="">
<input type="hidden" id="id" name="id" value="${userVo.id }">
<table cellpadding="0" cellspacing="0" class="l-table-edit" >
    <tr>
        <td align="right" class="l-table-edit-td"><font  color="red">*</font>真实姓名：</td>
        <td align="left" class="l-table-edit-td"><input name="realName" type="text" id="realName" maxlength="21" value="${userVo.realName }" /></td>
        <td align="left"></td>
    </tr>
    <tr>
        <td align="right" class="l-table-edit-td"><font  color="red">*</font>登录用户名：</td>
        <td align="left" class="l-table-edit-td"><input name="userName" type="text" id="userName" value="${userVo.userName }" maxlength="21"  style="ime-mode:disabled"/></td>
        <td align="left"></td>
    </tr>
</table><br>
<input type="submit" value="提交" id="Button1" class="l-button l-button-submit" /> 
<input type="button" value="取消" name="cancel" class="l-button l-button-cancel"/>
</form>
<div style="display:none">
<!--  数据统计代码 --></div>

<script type="text/javascript">
$(function ()
{
	jQuery.validator.addMethod("nameStr", function(value, element) {
		return this.optional(element) || /^[a-zA-Z\u4e00-\u9fa5]+$/.test(value);
	}, "只允许输入中文与字母");
	
	jQuery.validator.addMethod("user_exit",function(value,element){
		 var userName=$("#userName").val();
		 if (userName == '${userVo.userName }') return true;
			var rst = false;
			  $.ajax({
					type:"POST",
					url:"isUserExist.do",
					data:{"userName":userName},
					async : false,
					success:function(data){
						if(data=="yes"){
							rst = false;
						}else{
							rst = true;
						}
					}
				});
          return this.optional(element) || rst;
          
	  },"用户名已存在，请重输入");
	//validate
    $.metadata.setType("attr", "validate");
    var v = $("form").validate({
    	rules: {
    		"realName": {required: true,rangelength:[2,20],nameStr:true},
    		"userName": {required: true,rangelength:[2,20],userNumber:true,user_exit:true}
    	},
    	messages: {
    		"realName": {
    			required: "该字段不能为空",
    			rangelength: jQuery.validator.format("请输入{0}-{1}位字符")
    		},
    		"userName": {
    			required: "该字段不能为空",
    			rangelength: jQuery.validator.format("请输入{0}-{1}位字符")
    		}
    	},
        errorPlacement: function (lable, element)
        {
            if (element.hasClass("l-textarea"))
            {
            	lable.ligerHideTip();
                element.ligerTip({ content: lable.html(), target: element[0] }); 
            }
            else if (element.hasClass("l-text-field"))
            {
            	lable.ligerHideTip();
                element.parent().ligerTip({ content: lable.html(), target: element[0] });
            }
            else
            {
                lable.appendTo(element.parents("td:first").next("td"));
            }
        },        
        success: function (lable)
        {
            lable.ligerHideTip();
            lable.remove();
        },
        submitHandler:function()
        {
            $("form .l-text,.l-textarea").ligerHideTip();
            var options = {
            		type: 'POST',
            		success: function(data){
            			  if(data=="success") {
		            			var s=window.parent.$.ligerDialog.success("修改成功","提示",function () {
		            	        	parent.window.location.href = '../../../manager/system/user/userList.do';
		            	        });
		            	        $(s.dialog.winbtns).remove();
		            	        } else {
		            	          window.parent.$.ligerDialog.error("修改失败");
		            	   }
            		}
            	}, $form1 = $("#form1");
            $form1.ajaxSubmit(options);
            return false;
        }
    });
    $("form").ligerForm();
    $(".l-button-cancel").click(function ()
    {
    	parent.window.location.reload();
    });
});  
</script>
</body>
</html>